package com.beeantec.jnrerc.modules.common.controller;


import com.beeantec.jnrerc.core.api.ApiRest;
import com.beeantec.jnrerc.core.api.controller.BaseController;
import com.beeantec.jnrerc.dto.request.SmsReqDTO;
import com.beeantec.jnrerc.dto.response.SmsRespDTO;
import com.beeantec.jnrerc.modules.common.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;


@Api(tags={"短信"})
@RestController
@RequestMapping("/api/sms")
public class SmsController extends BaseController {
    @Autowired
    SmsService smsService;
    /**
     * 发送短信
     * @param smsReqDTO
     * @return
     */
    @PostMapping("/getSmsCode")
    @ApiOperation(value = "获取短信验证码", notes = "获取短信验证码")
    public ApiRest<String> getSmsCode(@RequestBody SmsReqDTO smsReqDTO) {
        String  result = smsService.sendSms(smsReqDTO.getPhone(),smsReqDTO.getType());
        if (result.equals("1")){
            return super.success("success");
        }
        return super.failure("failure");
    }

}
